package org.shop.common.until;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 功能概要：
 * 
 *
 */
public class PageResultList<T> extends AbstractPageResult<T> implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private List<T> dataList;//数据
	

	public List<T> getDataList() {
		
		return dataList;
	}

	public void setDataList(List<T> dataList) {
		
		if (dataList == null) {
			this.dataList = new ArrayList<>();
			return ;
		}
		this.dataList = dataList;
	}

	/**
	 * @param datas
	 * @param pageObj
	 * @return
	 */
	public static <T> PageResultList<T> getResult(List<T> datas, AjaxPage pageObj) {
		
		PageResultList<T> result = new PageResultList<T>();
		
        result.setPageNo(pageObj.getNowPage());
        result.setPageSize(pageObj.getListRows());
        result.setDataList(datas);
        result.setTotal(pageObj.getTotalRows());
        result.setPages(pageObj.getTotalPages());

        return result;
    }

}
